﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Hammock.Web;

namespace TMWS
{
	using Models;

	/// <summary>
	/// Multiplayer rankings service
	/// </summary>
	public class MultiplayerRankingService : ServiceBase
	{
		#region Constructors

		/// <summary>
		/// 
		/// </summary>
		/// <param name="username">API username</param>
		/// <param name="password">APU password</param>
		public MultiplayerRankingService(string username, string password)
			: base(username, password, false)
		{
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="username">API username</param>
		/// <param name="password">APU password</param>
		/// <param name="enableLogging">Enable logging</param>
		/// <param name="logDirectory">Directory to store logs</param>
		public MultiplayerRankingService(string username, string password, bool enableLogging, string logDirectory)
			: base(username, password, enableLogging, logDirectory)
		{
		}

		#endregion

		#region Public Methods

		/// <summary>
		/// Gets the top 10 multiplayer player rankings
		/// </summary>
		/// <returns>Rankings</returns>
		public PlayerRanking GetMultiplayerRankings(string path = "World", string environment = TrackManiaEnvironments.Merge, int offset = 0, int length = 10)
		{
			string resource = String.Format("tmf/rankings/multiplayer/players/{0}/{1}/?offset={2}&length={3}", path, environment, offset, length);

			return Execute<PlayerRanking>(resource, WebMethod.Get);
		}

		/// <summary>
		/// Gets the zone rankings
		/// </summary>
		/// <param name="path"></param>
		/// <param name="offset"></param>
		/// <param name="length"></param>
		/// <returns></returns>
		public ZoneRanking GetMultiplayerZoneRankings(string path = "World", int offset = 0, int length = 10)
		{
			string resource = String.Format("tmf/rankings/multiplayer/zones/{0}/?offset={1}&length={2}", path, offset, length);

			return Execute<ZoneRanking>(resource, WebMethod.Get);
		}

		#endregion
	}
}